<?php
if ( // 开启页面压缩
  !headers_sent() && // 如果页面头部信息还没有输出
  extension_loaded("zlib") && // 而且php已经加载了zlib扩展
  strstr($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") //而且浏览器接受GZIP
) {
  ini_set('zlib.output_compression', 'On');
  ini_set('zlib.output_compression_level', '5');
}
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
header("Access-Control-Allow-Headers: DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type");
function mPrint($val = '') {
  echo json_encode($val);
}
function mPrintX($val = '') {
  echo json_encode($val);
  die;
}

$data = json_decode(file_get_contents('php://input'), true);

if (isset($data['wx'])) $_POST = $data;

$h5 = false;
if (isset($_POST['h5']) && isset($_FILES['audio']) && isset($_FILES['audio']['tmp_name'])) {
  $_POST['h5'] = json_decode($_POST['h5'], true);
  $_POST['h5']['file'] = $_FILES['audio']['tmp_name'];
  $h5 = true;
}
if (isset($_POST['wx']) || $h5) {
  mPrintX($_POST);
}
mPrintX($h5);
